﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <link href="~/layuimini/css/public.css" rel="stylesheet" />
    <style>
    </style>
</head>
<body>
    <div class="layuimini-container">
        <div class="layuimini-main">
            <fieldset class="table-search-fieldset">
                <legend>库存调拨</legend>
                <div style="margin: 10px 10px 10px 10px">
                    <form class="layui-form layui-form-pane" action="">

                        <div class="layui-form-item">
                            <div class="layui-inline">
                                <label class="layui-form-label">流程卡</label>
                                <div class="layui-input-inline">
                                    <select name="BillNameID" lay-verify="required" lay-search id="BillNameID">
                                        <option value="0">全部</option>
                                        @Html.Raw(ViewBag.BillName)
                                    </select>
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button class="layui-btn layui-btn-normal" onclick="ShowSelectGoods('g')" type="button">选择产品</button>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">产品名称</label>
                                <div class="layui-input-inline">
                                    <input type="hidden" name="GoodsID" value="0" id="GoodsID" />
                                    <input type="text" name="GoodsName" autocomplete="off" class="layui-input" id="GoodsName" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline" style="display:none;">
                                <label class="layui-form-label">产品编号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="GoodsCode" autocomplete="off" class="layui-input" id="GoodsCode" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <label class="layui-form-label">产品型号</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="GoodsModel" autocomplete="off" class="layui-input" id="GoodsModel" disabled="disabled">
                                </div>
                            </div>
                            <div class="layui-inline">
                                <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                            </div>
                        </div>
                    </form>
                </div>
            </fieldset>
            <script type="text/html" id="toolbarDemo">
                {{#  if( @(Web.Common.Common.IsAuthoritys(28)) == 1){ }}
                <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 添加 </button>
                {{#  } }}
            </script>
            <table class="layui-hide" id="table" lay-filter="currentTableFilter"></table>
            <script type="text/html" id="currentTableBar">
                {{#  if( @(Web.Common.Common.IsAuthoritys(28)) == 1){ }}
                <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="del">删除</a>
                {{#  } }}
           </script>
        </div>
    </div>
    <script src="~/layui/layui.js"></script>
    <script src="~/layuimini/js/lay-config.js"></script>
    <script src="~/scripts/jquery-1.4.4.min.js"></script>

    <script>
        layui.use(['form', 'table', 'miniTab'], function () {
            var $ = layui.jquery,
                form = layui.form,
                table = layui.table,
                miniTab = layui.miniTab;

        table.render({
            elem: '#table',
            method: 'post',
            url: '@Url.Action("MoveBillListAsync", "GoodsStock")',
            request: {
                pageName: 'PageIndex' //页码的参数名称，默认：page
               , limitName: 'PageSize' //每页数据量的参数名，默认：limit
            },
            where: {
                GoodsID: $('#GoodsID').val(),
                BillNameID: $('#BillNameID').val()
            },
            cellMinWidth:120,
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                //{ type: "checkbox", width: 50 },
                { type: 'numbers', title: '序号', width: 50 },
                { field: 'ID', title: 'ID', width: 100, hide: true },
                //{ field: 'GoodsCode', title: '产品编码' },
                { field: 'GoodsName', title: '产品名称' },
                { field: 'GoodsModel', title: '产品型号' },
                { field: 'WaiXing', title: '外形' },
                { field: 'InBillName', title: '入库流程卡' },
                { field: 'BillCode', title: '流程卡号' },
                { field: 'OutBillName', title: '出库流程卡' },
                { field: 'Qty', title: '数量' },
                { field: 'InUserName', title: '接收人' },
                { field: 'OutUserName', title: '发出人' },
                { field: 'CreateTime', title: '调拨时间' },
                { fixed: 'right', title: '操作', toolbar: '#currentTableBar', width: 250 }
            ]],
            limits: [10, 20, 30, 50, 100, 100000000],
            limit: 20,
            page: true,
            //skin: 'line',
            //totalRow: true,
            height: 'full-170',
            size:'sm',
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            RefreshTable();
            return false
        });



        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加调拨',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: false,
                    area: ['1050px', '650px'],
                    content: '@Url.Action("MoveBillEdit", "GoodsStock")',
                    end: function () {
                        RefreshTable();

                    }
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });

            }
        });

        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('您确定要删除所选数据吗', {
                    btn: ['是的', '取消'] //按钮
                }, function () {
                    $.ajax({
                        url: '@Url.Action("MoveBillEditAsync", "GoodsStock")',
                        type: "post",
                        dataType: "json",
                        data: { ID: data.ID, Remark: '' },
                        success: function (obj) {
                            //Info,Success,Warning,Error
                            var type = obj.Type;
                            if (type == 1) {
                                layer.msg(obj.Content,
                                    {
                                        icon: 6, time: 2000
                                    },
                                    function () {
                                        RefreshTable();
                                    });
                            } else {
                                layer.msg(obj.Content, { icon: 5, time: 2000 });
                            }
                        }
                    });
                }, function () {
                    return;
                });
                return false;
            }
        });
        function RefreshTable() {
            table.reload('table', {
                where: {
                    GoodsID: $('#GoodsID').val(),
                    BillNameID: $('#BillNameID').val()
                }
            }, 'data');

        }

        });
        function ShowSelectGoods(back) {
            var index = layer.open({
                title: '选择产品',
                type: 2,
                shade: 0.2,
                maxmin: true,
                shadeClose: false,
                area: ['800px', '600px'],
                content: '@Url.Action("GoodsSelect", "BasicInfo")' + '?Back=' + back + '&TypeID=3',
            });
            return false;
        }
        function selectgoods(id, code, name, model, back) {
            if (back == 'g') {
                $('#GoodsID').val(id);
                $('#GoodsCode').val('名称：'+name+'｜型号'+model);
                //$('#GoodsCode').val('编号：' + code + '｜名称：' + name + '｜型号' + model);
                //$('#GoodsName').val(name);
                //$('#GoodsModel').val(model);
            }
        }

    </script>
</body>
</html>